package net.homelinux.chaoswg.io.renga.krypto.animations.Merge4;

import net.homelinux.chaoswg.io.renga.core.animations.State;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.Unsigned128Bit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.Unsigned16Bit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.Unsigned32Bit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.Unsigned64Bit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.Unsigned8Bit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.UnsignedNBit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.UnsignedNBitFactory;

public class Merge4State implements State {
    UnsignedNBit operand0 = new Unsigned8Bit();
    UnsignedNBit operand1 = new Unsigned8Bit();
    UnsignedNBit operand2 = new Unsigned8Bit();
    UnsignedNBit operand3 = new Unsigned8Bit();
    UnsignedNBit result = new Unsigned8Bit();

    public Merge4State () {}
    
    public Merge4State (UnsignedNBit operand0, UnsignedNBit operand1, UnsignedNBit operand2, UnsignedNBit operand3) {
        this.operand0 = operand0;
        this.operand1 = operand1;
        this.operand2 = operand0;
        this.operand3 = operand1;
        
        if (operand0 instanceof Unsigned8Bit) {
            this.result = new Unsigned8Bit ();
        } else if (operand0 instanceof Unsigned16Bit) {
            this.result = new Unsigned16Bit ();
            
        }else if (operand0 instanceof Unsigned32Bit) {
            this.result = new Unsigned32Bit ();
            
        } else if (operand0 instanceof Unsigned64Bit) {
            this.result = new Unsigned64Bit ();
            
        } else if (operand0 instanceof Unsigned128Bit) {
            this.result = new Unsigned128Bit ();
        }
    }
    
    public UnsignedNBit getOperand1() {
        return operand1;
    }
    public void setOperand1(UnsignedNBit operand1) {
        this.operand1 = operand1;
    }
    public UnsignedNBit getOperand0() {
        return operand0;
    }
    public void setOperand0(UnsignedNBit operand0) {
        this.operand0 = operand0;
    }
    
    public UnsignedNBit getResult() {
        return result;
    }
    public void setResult(UnsignedNBit result) {
        this.result = result;
    }

    public void setOperand(final int slot, final Object value) {
        if (value instanceof UnsignedNBit) {
            switch (slot) {
                case 0:
                    operand0 = ((UnsignedNBit)value);
                    result = UnsignedNBitFactory.createUnsignedNBitFactory().get(operand0.getN());
                    break;
                case 1:
                    operand1 = ((UnsignedNBit)value);
                    result = UnsignedNBitFactory.createUnsignedNBitFactory().get(operand1.getN());
                    break;
                case 2:
                    operand2 = ((UnsignedNBit)value);
                    result = UnsignedNBitFactory.createUnsignedNBitFactory().get(operand2.getN());
                    break;
                case 3:
                    operand3 = ((UnsignedNBit)value);
                    result = UnsignedNBitFactory.createUnsignedNBitFactory().get(operand3.getN());
                    break;
            }
        }
    }

    public UnsignedNBit getOperand2() {
        return operand2;
    }

    public void setOperand2(UnsignedNBit operand2) {
        this.operand2 = operand2;
    }

    public UnsignedNBit getOperand3() {
        return operand3;
    }

    public void setOperand3(UnsignedNBit operand3) {
        this.operand3 = operand3;
    }

}
